
$(document).ready(function(){
        if(window.location.href.indexOf("auth=fail") > 0){
          alert("User Id or Password is Incorrect");
          window.location.href = "/"; 
        }
        
        if(window.location.href.indexOf("result=success") > 0){
            alert("Registration successfully completed. \nPlease login with your email address and password.");
            window.location.href = "/"; 
        }
        
        if(window.location.href.indexOf("result=activated") > 0){
            alert("Your account is already activated.");
            window.location.href = "/"; 
        }
        
        if(window.location.href.indexOf("result=invalid") > 0){
            alert("Invalid Link.");
            window.location.href = "/";
        }
        
        if(window.location.href.indexOf("/activate?actid=") > 0){
        	var actId = window.location.href.split("actid=")[1];
//        	$("#activateUserFrame").attr("src", "http://localhost:8888/tugnav/actusr/?actid="+actId);
        	$("#activateUserFrame").attr("src", "http://buyer.yoursuppliernetwork.com/tugnav/actusr/?actid="+actId);
        }
        
//        if(window.location.href.indexOf("resetpassword") > 0){
//        	showResetPasswordModal();
//        }
      }
    );


function showForgotPassword(){
	$('<div> </div>')
	.html('<form style="padding:10px 10px 10px 10px" id="forgotPwdForm" method="post" action="/ysn/sendPwd" >Email: <input  style="width:262px;" type="text" name="email"> </form >').dialog({
		resizable: false,
		height:200,
		width:400,
		modal: true,
		title: "Forgot Password Form",
		closeOnEscape: false,
		//open: function(event, ui) { $(".ui-dialog-titlebar-close").hide(); },
		buttons: {
			"Cancel": function() {
				
				$( this ).dialog( "close" );
			},
			"Submit": function() {
				$("#forgotPwdForm").submit();
				$( this ).dialog( "close" );
			}
		}
	});
}

function showResetPasswordModal(){
	$('<div> </div>')
	.html('<form style="padding:10px 10px 10px 10px" id="setNewPasswordForm" method="post" action="/ysn/resetPwd" >New Password: <input  style="width:262px;" type="password" name="password"> </form >').dialog({
		resizable: false,
		height:200,
		width:400,
		modal: true,
		title: "Set New Password",
		closeOnEscape: false,
		//open: function(event, ui) { $(".ui-dialog-titlebar-close").hide(); },
		buttons: {
			"Cancel": function() {
				$( this ).dialog( "close" );
			},
			"Submit": function() {
				$("#setNewPasswordForm").submit();
				$( this ).dialog( "close" );
			}
		}
	});
}
